package com.monitor.dao;

import java.util.List;

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper;
import org.springframework.stereotype.Repository;


import com.base.dao.TemplateDaoImpl;
import com.data.entity.BaseDataDto;
@Repository("monitorDao")
public class MonitorDaoImpl extends TemplateDaoImpl<BaseDataDto, Integer>implements MonitorDao{
	/**
	 * 根据lineId获取所有设备实时状态
	 * @return
	 */
	@Override
	public List<BaseDataDto> findByLineId(int lineId, int equNum, String cond) {
		StringBuffer sb = new StringBuffer("SELECT top "+equNum+" id,equNo,U_a,I_a,P_active,Frequency,P_engry,[Time] from baseData")
			.append(" where equNo in ("+cond+")")
			.append(" GROUP BY equNo,id,U_a,I_a,P_active,Frequency,P_engry,[Time] ORDER BY [Time] DESC");
		return jt.query(sb.toString(), ParameterizedBeanPropertyRowMapper.newInstance(BaseDataDto.class));
	}
}
